/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
 */

package com.huawei.chengdu.meetingdemo.callback;

import com.device.idea.meeting.MeetingCallback;
import com.huawei.chengdu.meetingdemo.util.LogUtil;

/**
 * 类名：MeetingCallbackSelf
 * 描述：MeetingCallback封装类，可以更加灵活处理回调， 增加扩展性。
 */
public abstract class MeetingCallbackSelf<E> {
    private final MeetingCallback meetingCallback;

    public MeetingCallbackSelf(String info)  {
        meetingCallback = new MeetingCallback<E>() {
            @Override
            public void onSuccess(E e) {
                LogUtil.info(info + " onSuccess()");
                MeetingCallbackSelf.this.onSuccess(e);
            }

            @Override
            public void onFailed(int errCode, String errMsg) {
                LogUtil.error(info + " onFailed()");
                MeetingCallbackSelf.this.onFailed(errCode, errMsg);
            }
        };
    }

    /**
     * 获取MeetingCallback
     *
     * @return 返回MeetingCallback
     */
    public MeetingCallback<E> getMeetingCallback() {
        return meetingCallback;
    }

    /**
     * 成功回调
     *
     * @param e 成功返回的信息
     */
    public abstract void onSuccess(E e);

    /**
     * 失败回调
     *
     * @param errCode 错误码
     * @param errMsg 错误信息
     */
    public abstract void onFailed(int errCode, String errMsg);
}
